<template>
  <a-card :bordered="false">

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
      </a-dropdown>
    </div>

    <!-- table区域-begin -->
    <div>
      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        class="j-table-force-nowrap"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        @change="handleTableChange">

      </a-table>
    </div>
    <!-- table区域-end -->

    <!-- 表单区域 -->
    <stmChannelProductApplyItem-modal ref="modalForm" @ok="modalFormOk"></stmChannelProductApplyItem-modal>
  </a-card>
</template>

<script>
  import '@/assets/less/TableExpand.less'
  import stmChannelProductApplyItemModal from './modules/stmChannelProductApplyItemModal'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import {getAction} from "@api/manage";

  export default {
    name: "StmChannelProductApplyItemList",
    mixins:[JeecgListMixin],
    components: {
      stmChannelProductApplyItemModal
    },
    data () {
      return {
        description: '申请明细表管理页面',
        // 表头
        columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title: '商品名称',
            align:"center",
            dataIndex: 'productName'
          },
		   {
            title: '货号',
            align:"center",
            dataIndex: 'productSn'
		   },
		   {
            title: '物料编码',
            align:"center",
            dataIndex: 'skuCode'
		   },
		   {
            title: '价格',
            align:"center",
            dataIndex: 'price'
		   },

		   {
            title: '生效日期',
            align:"center",
            dataIndex: 'beginTime'
		   },
        ],
		url: {
          list: "/stm/stmChannelProductApplyItem/list",
          delete: "/stm/stmChannelProductApplyItem/delete",
          deleteBatch: "/stm/stmChannelProductApplyItem/deleteBatch",
          exportXlsUrl: "stm/stmChannelProductApplyItem/exportXls",
          importExcelUrl: "stm/stmChannelProductApplyItem/importExcel",
        },
       }
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      }
    },
    methods: {
      loadData(arg) {
        if (arg === 1) {
          this.ipagination.current = 1
        }
        var params = this.getQueryParams()
        getAction(this.url.list, {
          applyId: params.mainId,
          status:2
          , pageNo: this.ipagination.current, pageSize: this.ipagination.pageSize
        }).then((res) => {
          if (res.success) {
            this.dataSource = res.result.records
            this.ipagination.total = res.result.total
          } else {
            this.dataSource = null
          }
        })
      },
      getMain(mainId) {
        this.queryParam.mainId = mainId
        this.loadData(1)
      },
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>